package com.yuwei.goods_detail.adapter

import android.widget.ImageView
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.bumptech.glide.Glide
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.yuwei.goods_detail.R
import com.yuwei.goods_detail.entity.CommentUserEntityItem

class DetailCommentAdapter : BaseQuickAdapter<CommentUserEntityItem, BaseViewHolder>(R.layout.item_detail_comment) {
    private var  position = 0
    fun setPosition(position: Int) {
        this.position = position
    }
    private var commentSatisfactionAdapter = CommentSatisfactionAdapter()
    private var list = mutableListOf<Int>(R.drawable.round_star,R.drawable.round_star,R.drawable.round_star,R.drawable.round_star,R.drawable.round_star)
    override fun convert(holder: BaseViewHolder, item: CommentUserEntityItem) {
        val imageView = holder.getView<ImageView>(R.id.item_detail_comment_iv)
        Glide.with(context).load(if (item.userlogo.isEmpty())R.drawable.a else item.userlogo).circleCrop().into(imageView)
        holder.setText(R.id.item_detail_comment_tv,item.nickname)
        holder.setText(R.id.item_detail_comment_time,item.createtime)
        holder.setText(R.id.item_detail_comment_conent,item.content)
        val rv = holder.getView<RecyclerView>(R.id.item_detail_comment_rv)
        rv.adapter= commentSatisfactionAdapter
        rv.layoutManager = LinearLayoutManager(context,  LinearLayoutManager.HORIZONTAL, false)
        commentSatisfactionAdapter.data.clear()
        commentSatisfactionAdapter.data.addAll(list)
        commentSatisfactionAdapter.notifyDataSetChanged()


    }
}